package
{
	import _effx.FuseSpark;
	
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.events.MouseEvent;
	
	public class FuseSparkMain extends Sprite
	{
		public function FuseSparkMain()
		{
         addEventListener(Event.ADDED_TO_STAGE, onAdd);
         addEventListener(Event.REMOVED_FROM_STAGE, onRemove);
		}
      
      // ################### protected ##################
      
      protected function onAdd(e:Event):void
      {
         // basic
         stage.scaleMode = StageScaleMode.NO_SCALE;
         stage.align = StageAlign.TOP_LEFT;
         
         // init effect
         FuseSpark.init(stage);
         
         // mouse down
         stage.addEventListener(MouseEvent.MOUSE_DOWN, onMDown);
      }
      
      protected function onRemove(e:Event):void
      {
      }
      
      // --------------------- LINE ---------------------
      
      protected function onMDown(e:MouseEvent):void
      {
         makeSpark();
         stage.addEventListener(Event.ENTER_FRAME, makeSpark);
         stage.addEventListener(MouseEvent.MOUSE_UP, onMUp);
      }
      
      protected function makeSpark(e:Event = null):void
      {
         FuseSpark.addPulse(stage.mouseX, stage.mouseY);
      }
      
      protected function onMUp(e:MouseEvent):void
      {
         stage.removeEventListener(Event.ENTER_FRAME, makeSpark);
         stage.removeEventListener(MouseEvent.MOUSE_UP, onMUp);
         
         FuseSpark.stop();
      }
      
      // #################### private ###################
      
      // --------------------- LINE ---------------------
      
	}
   
}